class Solution {
public:
    int numberOfBeams(vector<string>& bank) {

        unordered_map<int, int> map;

        int k = 0;
        for (int i = 0; i < bank.size(); i++) {

            bool flag = false;
            for (int j = 0; j < bank[i].size(); j++) {
                if (bank[i][j] == '1') {
                    map[k]++;
                    flag = true;
                }
            }
            if (flag) k++;
        }

        int res = 0;
        for (int i = 0; i < map.size() - 1; i++) {

            res += map[i] * map[i + 1];
        }

        return res;
    }
};